package com.jerry.secondkill.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jerry.secondkill.dao.TestDataDao;
import com.jerry.secondkill.domain.TestData;

@Service
public class TestDataService {
	
	@Autowired
	TestDataDao testDataDao;
	
	public TestData getById(int id) {
		 return testDataDao.getById(id);
	}

	public boolean insert() {
		
		TestData data1= new TestData();
		data1.setId(1);
		data1.setName("111");
		testDataDao.insert(data1);
		
		return true;
	}
	
	@Transactional
	public boolean insertByTransactional() {
	
		TestData data2= new TestData();
		data2.setId(2);
		data2.setName("222");
		testDataDao.insert(data2);
		
		TestData data1= new TestData();
		data1.setId(1);
		data1.setName("111");
		testDataDao.insert(data1);
		
		return true;
	}
	
}